import java.util.Random;                          //导入随机数字类和scanner扫描器类
import java.util.Scanner;
public class GuessNumber {
    public static void main(String[] args) {
        Random r = new Random();                                 //生成一个随机数字
        int random = r.nextInt(100)+1;                           //随机数字的范围
        Scanner scanner = new Scanner(System.in);
        for(int i = 0; i<10;i++){                               //限制猜测数字的次数
            System.out.println("请输入猜测的数字: ");
            int guess = scanner.nextInt();    //接收一个玩家猜测的数字
            if(random<guess){
                System.out.println("数字太大，请重试");
            }else if (random>guess){
                System.out.println("数字太小，请重试");
            }else{
                System.out.println("猜测成功");
                break;
            }
        }
        System.out.println("次数已用完，游戏结束");
}